import { Component,OnInit } from '@angular/core';
import { Hero } from '../../modal/hero';
import { HeroService } from '../../controller/hero.service';


@Component({
  selector: 'my-hcsy',
  templateUrl: './heroes.component.html',
  styleUrls: ['./heroes.component.css']
})
export class HeroesComponent implements OnInit {
  title = 'Tour of Heroes';

  heroes:Hero[];

  selectedHero: Hero;

 constructor(private heroService: HeroService) { }
 
  getHeroes(): void {
    this.heroService.getHeroes().then(heroes => this.heroes = heroes);
  }
  ngOnInit(): void {
    this.getHeroes();
  }


  onSelect(hero: Hero): void {
      console.log(hero);
     this.selectedHero = hero;
     console.log(this.selectedHero);
  }

 
}

